package com.nulldev.util.java.swing.extSwing.legacy;

import java.awt.event.MouseEvent;

import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;

@Deprecated
public class eAbout extends ePanel{

	public eAbout() {
		super("eSwing: About");
		setBounds(100, 100, 250, 250);
		setDefaultCloseOperation(ePanel.HIDE_ON_CLOSE);
		setResizable(false);
		
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.CENTER);
		
		JLabel lblEswing = new JLabel("eSwing");
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon(eAbout.class.getResource("/com/nulldev/util/java/swing/extSwing/icon.png")));
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panel.createSequentialGroup()
							.addGap(97)
							.addComponent(lblEswing))
						.addGroup(gl_panel.createSequentialGroup()
							.addGap(107)
							.addComponent(label)))
					.addContainerGap(103, Short.MAX_VALUE))
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addGap(36)
					.addComponent(label)
					.addGap(18)
					.addComponent(lblEswing)
					.addContainerGap(144, Short.MAX_VALUE))
		);
		panel.setLayout(gl_panel);
	}
	
	@Override
	public void init() {

	}
	
	@Override
	public void mousePressed(MouseEvent e) {
        initialClick = e.getPoint();
        getComponentAt(initialClick);
		if ((e.getX() > getWidth() - 15 && e.getX() < getWidth() - 5) && (e.getY() > 8 && e.getY() < 20)) {
			this.toggle();
		}else if ((e.getX() > getWidth() - 30 && e.getX() < getWidth() - 20) && (e.getY() > 8 && e.getY() < 20)) {
			if (this.isResizable()) {
				if (this.getExtendedState() == MAXIMIZED_BOTH) {
					this.setExtendedState(this.NORMAL);
				}else {
					this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
				}
			}
		}else if ((e.getX() > getWidth() - 45 && e.getX() < getWidth() - 35) && (e.getY() > 8 && e.getY() < 20)) {
			this.setExtendedState(this.ICONIFIED);
		}
	}
}
